package com.ctesi.utils;

import us.codecraft.webmagic.Page;

public class PutUtil {
    public static void putField(Page page, String bidContext, String pattern, String value){
        String extraction = StringExtract.extractTextByRegex(bidContext,pattern);
        if (extraction == null){
            page.putField(String.format("%s",value),"无法获取到，请查询对应url。");
        }else {
            if (value == "bidId"){
                extraction = StringExtract.removeSpaces(extraction).replaceAll("[^a-zA-Z0-9]", "");;
                page.putField(String.format("%s",value),extraction);
            }
            else {
                extraction = StringExtract.removeSpaces(extraction);
                extraction = StringExtract.removeNbsp(extraction);
                page.putField(String.format("%s",value),extraction);
            }

        }
    }
}
